var captain = JSON.parse(localStorage.getItem("captain"));
console.log(localStorage.getItem("captain")); 
//获取token
var token = localStorage.getItem("token");	
console.log('token：'+token)
var radioVal=1;
var tagData = [];
hui.formInit(); 
var loves; 
//获取单选框的值
function showSelectRes(_selfBtn){
    
    hui(_selfBtn).parent().find('input').each(function(cObj){
        if(cObj.checked){radioVal = cObj.value;}
    });
    console.log(radioVal);
} 

//获取居民疾病标签
function getilllabel(dataInfo){
	hui.ajax({
	    type : 'POST',
	    url : globleobj['domain']+'/residents/getilllabel',
	    data : {},
	    beforeSend : function(){hui.loading();},
	    complete   : function(){hui.closeLoading();},
	    success : function(msg){
	    	console.log('getilllabel'+msg) 
	    	var data = JSON.parse(msg);
	    	if(data.rc != 0){
	    		hui.toast(data.msg); 
	    		return false; 
	    	}
	    	
			var options = ''; 
			for(var i = 0; i < data.result.length;i++){
				options += '<div tagVal="'+data.result[i]._id+'">'+data.result[i].title+'</div>'
			}
			hui('#tags1').html(options);
	    	
	    	hui.tags('#tags1', function(){
			    tagData = hui.getTagsData('#tags1');  
			    console.log(JSON.stringify(tagData)); 
			    if(tagData.tagsText.length>6){
			    	hui.toast('最多选中6个'); 
			    }
			});
	    },
	    error : function(e){
	        console.log(JSON.stringify(e));
	        hui.iconToast('读取消息失败', 'warn');
	    } 
	}); 
}
hui.ready(function(){
	getilllabel();
	hui(".teamName").html(captain.captain.name);
	hui('#hui-back').click(function(){
//	    hui.toast('返回'); 
	});
	
	hui('#submitBtn').click(function(){
	    var res = huiFormCheck('#form1');
	    //提交
	    if(res){
	    	var dataInfo = {
	    		'hos_id':captain.captain.hos_id,
	    		'group_id':captain.captain.group_id,
	    		'realname':hui("#userName").val(),
	    		'street':hui("#street").val(),
	    		'address':hui("#address").val(),
	    		'idcard':hui("#idcard").val(),
	    		'disease_labels':tagData.tagsText,
	    		'sign_channel':radioVal,
	    		'token':token
	    	}
	    	console.log(JSON.stringify(dataInfo))
	    	localStorage.setItem("signInfo",JSON.stringify(dataInfo))
	    	//hui.iconToast('验证通过！');
	        setTimeout(function(){
	        	hui.open('signSure.html',{},true);
	        },300)
	        
	    }
	});
	
//	//跳转个人中心
//	hui('#nav-my').click(function(){
//	    hui.open('personcenter.html')
//	});
    hui.plusReady(function(){
    	console.log('plusReady')
    });
});